CoffeeScript Application Development by 2013

CoffeeScript Application Development by 2013

Author:2013
Language: eng
Format: epub
Publisher: Packt Publishing


For each object in the array, we build a new class instance. Thanks to the for loop acting as an expression and CoffeeScript's implicit function returns, this is all we need to do for this function to return an array of Animal objects.

We're ready to start using our Animal class in the application. Remember to add it to index.html:

<script src="person.js"></script> <script src="animal.js"></script> <script src="setup.js"></script>

Note

Keeping track of all the JavaScript files can become a nuisance once you have many classes to deal with. If your application has a build process that uses a JavaScript minifier, you can set it to concatenate all your files first, so only one <script> tag is needed. Another solution is to use a module system such as RequireJS or cujo.js. These allow you to easily manage dependencies, and as a bonus will help you avoid polluting the global scope.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.